file = gtk_places_sidebar_get_location (GTK_PLACES_SIDEBAR (priv->places_sidebar));
if (file)
{
- gchar *location;
- location = g_file_get_uri (file);
- gtk_query_set_location (priv->search_query, location);
- g_free (location);
+ gtk_query_set_location (priv->search_query, file);
g_object_unref (file);
}
struct _GtkQueryPrivate
{
gchar *text;
- gchar *location_uri;
+ GFile *location;
GList *mime_types;
gchar **words;
};
query = GTK_QUERY (object);
+ g_clear_object (&query->priv->location);
g_free (query->priv->text);
- g_free (query->priv->location_uri);
g_strfreev (query->priv->words);
G_OBJECT_CLASS (gtk_query_parent_class)->finalize (object);
query->priv->words = NULL;
}
-const gchar *
+GFile *
gtk_query_get_location (GtkQuery *query)
{
- return query->priv->location_uri;
+ return query->priv->location;
}
void
-gtk_query_set_location (GtkQuery *query,
- const gchar *uri)
+gtk_query_set_location (GtkQuery *query,
+ GFile *file)
{
- g_free (query->priv->location_uri);
- query->priv->location_uri = g_strdup (uri);
+ g_set_object (&query->priv->location, file);
}
static gchar *
#ifndef __GTK_QUERY_H__
#define __GTK_QUERY_H__
-#include <glib-object.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
void gtk_query_set_text (GtkQuery *query,
const gchar *text);
-const gchar *gtk_query_get_location (GtkQuery *query);
+GFile *gtk_query_get_location (GtkQuery *query);
void gtk_query_set_location (GtkQuery *query,
- const gchar *uri);
+ GFile *file);
gboolean gtk_query_matches_string (GtkQuery *query,
const gchar *string);
GtkQuery *query)
{
SearchThreadData *data;
- const gchar *uri;
GFile *location;
data = g_new0 (SearchThreadData, 1);
data->directories = g_queue_new ();
data->query = g_object_ref (query);
data->recursive = _gtk_search_engine_get_recursive (GTK_SEARCH_ENGINE (engine));
- uri = gtk_query_get_location (query);
- if (uri != NULL)
- location = g_file_new_for_uri (uri);
+ location = gtk_query_get_location (query);
+ if (location)
+ g_object_ref (location);
else
location = g_file_new_for_path (g_get_home_dir ());
g_queue_push_tail (data->directories, location);
{
GtkSearchEngineTracker *tracker;
const gchar *search_text;
- const gchar *location_uri;
+ GFile *location;
GString *sparql;
gboolean recursive;
}
search_text = gtk_query_get_text (tracker->query);
- location_uri = gtk_query_get_location (tracker->query);
+ location = gtk_query_get_location (tracker->query);
recursive = _gtk_search_engine_get_recursive (engine);
sparql = g_string_new ("SELECT nie:url(?urn) "
sparql_append_string_literal_lower_case (sparql, search_text);
g_string_append (sparql, ")");
- if (location_uri)
+ if (location)
{
+ gchar *location_uri = g_file_get_uri (location);
g_string_append (sparql, " && ");
if (recursive)
g_string_append (sparql, "tracker:uri-is-descendant(");
g_string_append (sparql, "tracker:uri-is-parent(");
sparql_append_string_literal (sparql, location_uri, FALSE);
g_string_append (sparql, ",nie:url(?urn))");
+ g_free (location_uri);
}
g_string_append (sparql, ")");